﻿#pragma once
#ifndef MYSERVER_H
#define MYSERVER_H

#include <QObject>
#include <QTcpServer>
#include <QList>
#include "mytcpsocket.h"
#include "mythread.h"

class MyThread;

class MyServer : public QTcpServer
{
    Q_OBJECT
public:
    MyServer();
    ~MyServer();
    void incomingConnection(qintptr handle);
    static MyServer& getInstance();
    void transmitOnline(int msg,MyTcpSocket* sock,userInfo u);//向其他客户端发送自己上线消息
    void transmitOnline(int msg,MyTcpSocket* sock,userInfo u,char* content);//客户端私聊消息转发的重载
    void handleAddFriend(const char* name,userInfo src);//向目标转发加好友请求
    void transmitGroupRegS(PDU*& pdu,userInfo u);//转发注册群聊成功
    void transmitGroupMsg(PDU*& pdu,userInfo u,QString msg,MyTcpSocket* sock);//转发群聊消息
signals:

public slots:
    void deleteSocket(MyTcpSocket* sock);
private:
    QList<MyTcpSocket*> m_socketList;//管理socket
    QList<MyThread* > m_threadList;//管理线程
};

#endif // MYSERVER_H
